
//yw 1初始化
layui.use(['form','layer','flow','table','element'],function(){
	var $ = layui.jquery;
	var form = layui.form;
	var table= layui.table;
	var layer = layui.layer;
	var flow = layui.flow;
	var tbuildid = decodeURI(request("tbuildid"));
	var classroomid = decodeURI(request("classroomid"));

	// var isLoaded = false;
	// function reqs(){
	// 	$.ajax({
	// 		type:"POST",
	// 		async:false,
	// 		url:'/device/queryDeviceAirbox?buildId='+tbuildid+"&classroomId="+classroomid+"&controlMode="+controlMode,
	// 		success:function(res){
	// 			data1 = res.data;
	// 			console.log(data1);
	// 			$("#CurrentTemperature").html(data1[i].currentTemperature);
	// 			$("#CurrentHumidity").html(data1[i].currentHumidity);
	// 			$("#PM25").html(data1[i].pm25);
	// 			$("#CO2").html(data1[i].co2);
	// 			$("#HCHO").html(data1[i].hcho);
	// 		}
	// 	});
	// }
	// reqs();
	// setInterval(function(){
	// 	isLoaded&&reqs();
	// },3000);
	$(function(){
		// 轮播图
		var left = $(".new_post>.left");
		var right = $(".new_post>.right");
		var n = $(".new_post_banner ul li").length;
		var ul_length = $(".new_post_banner").outerWidth();
		var s=0;
		var tbuildName = decodeURI(request("tbuildname"));
		var classroom = decodeURI(request("classroom"));

		$("#ltbuildclass").html(tbuildName+classroom);

		left.click(function(){
			if(s==1){
				return false;
			}
			s= 1;
			$(".new_post_banner ul").animate({marginLeft:-ul_length-10+'px'},1000,function(){  //10为li元素的外边距 如果此处大于10会有震荡效果
				for(i=0;i<4;i++){
					$(".new_post_banner ul>li").eq(0).appendTo(".new_post_banner ul");
					$(".new_post_banner ul").css("marginLeft","0px");
				}
				s=0;
			});
		});
		right.click(function(){
			if(s==1){
				return false;
			}
			s=1;
			for(i=0;i<4;i++){
				$(".new_post_banner ul>li").eq(n-1).prependTo(".new_post_banner ul");
			}
			$(".new_post_banner ul").css("marginLeft",-ul_length-10+'px');
			$(".new_post_banner ul").animate({marginLeft:"0px"},1000,function(){
				s=0;
			});
		});
		detailInfo(tbuildid,classroomid,"");
	});

	//$("#classMode").click(function (tbuildid,classroomid){
	$(document).on('click', '#classMode', function() {
		//yw 清除ul中的数据
		var div = document.getElementById("Images");
		while(div.hasChildNodes()) //当div下还存在子节点时 循环继续  
		{
			div.removeChild(div.firstChild);
		}
		detailInfo(tbuildid,classroomid,"classMode");

	});
	$(document).on('click', '#finishClassMode', function() {
		//yw 清除ul中的数据
		var div = document.getElementById("Images");
		while(div.hasChildNodes()) //当div下还存在子节点时 循环继续  
		{
			div.removeChild(div.firstChild);
		}
		detailInfo(tbuildid,classroomid,"finishClassMode");
	});
	$(document).on('click', '#manualMode', function() {
		//yw 清除ul中的数据
		var div = document.getElementById("Images");
		while(div.hasChildNodes()) //当div下还存在子节点时 循环继续  
		{
			div.removeChild(div.firstChild);
		}
		detailInfo(tbuildid,classroomid,"manualMode");
	});
	//yw 得到url中的参数
	function request(params) {
		var url = location.href;
		var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
		var paraObj = { };
		for (i = 0; j = paraString[i]; i++) {
			paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
		}
		var returnValue = paraObj[params.toLowerCase()];
		if (typeof (returnValue) == "undefined") {
			return "";
		} else {
			return returnValue;
		}
	}
	//yw 3操作 详情
	function detailInfo(tbuildid,classroomid,controlMode){
		//var tbuildid = "12409";
		//var tbuildid = decodeURI(request("tbuildid"));
		//var classroomid = "4091";
		//var classroomid = decodeURI(request("classroomid"));
		//alert("detail")
		//console.log(tbuildid+classroomid);
		//yw 清除ul中的数据
		var div = document.getElementById("Images");
		while(div.hasChildNodes()) //当div下还存在子节点时 循环继续  
		{
			div.removeChild(div.firstChild);
		}
		imgNums = 30;
		flow.load({
			elem: '#Images', //流加载容器
			//isAuto:flase,//false点击加载更多才会加载
			isLazyimg:true,
			end:'',
			done: function(page, next){ //到达临界点（默认滚动触发），触发下一页
				$.ajax({
					type:"POST",
					async:false,
					//获取教室设备
					url:'/device/queryDeviceByClassId?classroomId='+classroomid,
					// url:'/device/queryDevicesByTbuildIDClassroomId?buildId='+tbuildid+"&classroomId="+classroomid+"&controlMode="+controlMode,
					success:function(res){
						//模拟插入
						var imgList = [],data1 = res;
						// var imgList = [],data1 = res.data;
						//console.log(data1);
						var maxPage = imgNums*page < data1.length ? imgNums*page : data1.length;
						setTimeout(function(){
							if(maxPage>0){
								for (var i=0; i<maxPage; i++) {
									var li = "<li><dl id='test'>";
									// if(data1[i].onlstatus=='1')
									// 	li+= "<dt><span style='color:blue;padding-left: 150px'>在线</span></dt>";
									// else
									// 	li+= "<dt><span style='color:white;padding-left: 150px'>离线</span></dt>";
									li+= "<dd><img style='width:100px;height:100px;padding-left: 50px' lay-src='../../images/"+data1[i].eqtype+".png'></dd>";
									// li+= "<dd><img style='width:100px;height:100px;padding-left: 50px' lay-src='../../images/"+data1[i].eqtypename+".png'></dd>";
									li+="<dd style='width:220px;text-align:center'>"+ data1[i].eqtype +"</dd>";
									li+= "<dd>设备编号："+data1[i].eqid+"</dd>";
									switch(data1[i].eqtype){

										case "窗帘":
											if(data1[i].powerSwitch=='1')
												li+= "<dd id='test1'><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='curtainPowerSwitch1' class='layui-btn layui-btn-normal'>关闭</button>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='curtainPowerSwitch0' class='layui-btn layui-btn-primary'>打开</button>";
											if(data1[i].pauseSwitch=="1")
												li+="<button type='button' eqid='"+data1[i].eqid+"' propertyName='pauseSwitch' propertyValue='1' id='curtainPauseSwitch1' class='layui-btn layui-btn-primary'>继续</button></dd>"
											else
												li+="<button type='button' eqid='"+data1[i].eqid+"' propertyName='pauseSwitch' propertyValue='0' id='curtainPauseSwitch0' class='layui-btn layui-btn-normal'>停止</button></dd>"
											break;
										case "三键开关":
											if(data1[i].powerSwitch_1=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_1' propertyValue='1' id='3keyPowerSwitch1_1' class='layui-btn layui-btn-normal'>关闭</button>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_1' propertyValue='0' id='3keyPowerSwitch1_0' class='layui-btn layui-btn-primary'>打开</button>";
											if(data1[i].powerSwitch_2=='1')
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_2' propertyValue='1' id='3keyPowerSwitch2_1' class='layui-btn layui-btn-normal'>关闭</button>";
											else
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_2' propertyValue='0' id='3keyPowerSwitch2_0' class='layui-btn layui-btn-primary'>打开</button>";
											if(data1[i].powerSwitch_3=='1')
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_3' propertyValue='1' id='3keyPowerSwitch3_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_3' propertyValue='0' id='3keyPowerSwitch3_0'  class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "双键开关":
											if(data1[i].powerSwitch_1=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_1' propertyValue='1' id='2keyPowerSwitch1_1' class='layui-btn layui-btn-normal'>关闭</button>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_1' propertyValue='0' id='2keyPowerSwitch1_0' class='layui-btn layui-btn-primary'>打开</button>";
											if(data1[i].powerSwitch_2=='1')
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_2' propertyValue='1' id='2keyPowerSwitch2_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch_2' propertyValue='0' id='2keyPowerSwitch2_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "空气盒子":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='airBoxPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='airBoxPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "空调":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='airConditionerPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='airConditionerPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "幕布":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='screenPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='screenPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "单键开关":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='1keyPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='1keyPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "五孔插座":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='5holePowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='5holePowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "10A移动插座":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='10AMobileSocketPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='10AMobileSocketPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "红外转发器":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='infraredTransPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='infraredTransPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "灯":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='lampPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='lampPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "吊扇":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='ceilingFanPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='ceilingFanPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "音箱":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='loudspeakerPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='loudspeakerPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										case "网关":
											if(data1[i].powerSwitch=='1')
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='gatewayPowerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
											else
												li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='gatewayPowerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
											break;
										default:
										// if(data1[i].powerSwitch=='1')
										// 	li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='1' id='powerSwitch_1' class='layui-btn layui-btn-normal'>关闭</button></dd>";
										// else
										// 	li+= "<dd><button type='button' eqid='"+data1[i].eqid+"' propertyName='powerSwitch' propertyValue='0' id='powerSwitch_0' class='layui-btn layui-btn-primary'>打开</button></dd>";
										// break;

									}
									//li+= "<dd><button type='button' class='layui-btn layui-btn-normal'>关闭</button><button type='button'class='layui-btn layui-btn-primary'>打开</button><button type='button' class='layui-btn layui-btn-normal'>关闭</button></dd>";
									li+= "</dl></li>";
									imgList.push(li);
								}
							}else{
								imgList.push('<li>没有关联本网关的设备</li>');
							}
							next(imgList.join(''), page < res.pages);  //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多 
							form.render();
						}, 200);

					}
				});
			}
		});//flow 
	}

	$(document).on('click','#airBoxPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#airBoxPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#airConditionerPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#airConditionerPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#screenPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#screenPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#1keyPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#1keyPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#5holePowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#5holePowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#10AMobileSocketPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#10AMobileSocketPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#infraredTransPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#infraredTransPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#lampPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#lampPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#ceilingFanPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#ceilingFanPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#loudspeakerPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#loudspeakerPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#powerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#powerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#2keyPowerSwitch1_0',function(){

		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#2keyPowerSwitch1_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#2keyPowerSwitch2_0',function(){

		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#2keyPowerSwitch2_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});

	$(document).on('click','#2keyPowerSwitch3_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#3keyPowerSwitch1_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#3keyPowerSwitch1_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#3keyPowerSwitch2_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#3keyPowerSwitch2_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});

	$(document).on('click','#3keyPowerSwitch3_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#3keyPowerSwitch3_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#curtainPowerSwitch1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#curtainPowerSwitch0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#curtainPauseSwitch1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#curtainPauseSwitch0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#gatewayPowerSwitch_1',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	$(document).on('click','#gatewayPowerSwitch_0',function(){
		setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	});
	// $(document).on('click','#curtainPowerSwitch1',function(){
	// 	// var eqId = $(this).attr("eqid");
	// 	// var propertyName = $(this).attr("propertyName");
	// 	// var propertyValue = $(this).attr("propertyValue");
	// 	// var controlName = $(this).attr("id");
	// 	setProperty($(this).attr("eqid"),$(this).attr("propertyName"),$(this).attr("propertyValue"),$(this).attr("id"));
	// });
	function setProperty(eqId,propertyName,propertyValue,controlName){
		$.ajax({
			type:"post",
			url:"/device/setProperty",
			data:{eqid:eqId,propertyname:propertyName,propertyvalue:propertyValue},
			success:function(res){
				if(res){
					console.log(eqId+propertyName+propertyValue+controlName);
					var button = document.getElementById(controlName);
					console.log(button); //debug
					if(button.attributes.propertyvalue.nodeValue=="1"){
						if(button.attributes.propertyname.nodeValue=="pauseSwitch")
							button.innerText = "继续";
						else
							button.innerText = "打开";
						button.className = "layui-btn layui-btn-primary";
						button.attributes.propertyvalue.nodeValue = "0";
					}
					else{
						if(button.attributes.propertyname.nodeValue=="pauseSwitch")
							button.innerText = "停止";
						else
							button.innerText = "关闭";
						button.className = "layui-btn layui-btn-normal";
						button.attributes.propertyvalue.nodeValue = "1";
					}

				}
			}
		});
	}


});
